<?php

	$TEMP->set_file(array('handle' => DIR_IFRAME_VIEW . 'irRequestStudentSection.html'));
	
	$studID 	= $_GET['id'];
	$semLinkID	= $_GET['slid'];
	
	$strStudPictureName = $globalCon->getStudentPictureName($studID);
	$strName			= $strStudPictureName['name'];
	$strAccNo			= $strStudPictureName['stud_no'];
	$courseID			= $strStudPictureName['course_idPK'];
	$courseCode			= $strStudPictureName['course_code'];
	$courseDesc			= $strStudPictureName['course_desc'];
	
	$studentSection = $globalCon->getStudentSection($studID, $semLinkID, $activeYear);
	$sectionID		= $studentSection['section_idPK'];
	$sectionDesc	= $studentSection['section_desc'];
	$sectionSemID 	= $studentSection['stud_sem_idPK'];
	
	$profSectionList = $STUD->getStudentChangeSectionActive($studID, $courseID, $semLinkID, $activeYear);
	
	$irregularRequestedSchedule = $STUD->getIrregularRequestedSchedule($studID, $semLinkID);
	
	# LSITING
	if ( !empty($irregularRequestedSchedule) ) {
		
		$TEMP->set_block('handle',  'students', 'studentsRow');
		$bgcolor 	= LOOPING_F0F;
		$numCount 	= 1;
		$html		= '';
		foreach($irregularRequestedSchedule as $studListField => $studListValue) {
			
			$title 		= ($studListField == 'Y') ? '<span style="color:#00F">Requested</span>' : '<span style="color:#F00">Subject</span>';
			$html 		= '<tr class="hover-light" ' . LOOPING_F0F . '><td align="left" class="td-record" colspan="6" height="20">&nbsp;&nbsp;<strong>' . $title . '</strong></td></tr>';
			$subj_list 	= '';
			
			if ( !empty($studListValue) ) {
				foreach($studListValue as $value) {
					switch($value['lec_lab_both']) {
						case '0': $lecLabBoth = 'Lecture'; break;
						case '1': $lecLabBoth = 'Laboratory'; break;
						case '2': $lecLabBoth = 'Lec/Lab'; break;
					}
					
					$subj_list .= '<tr class="hover-light" align="left">
										<td class="td-record" height="19">&nbsp;&nbsp;' . $value['subj_code'] . '</td>
										<td class="td-record">&nbsp;' . $value['sched_day'] . '</td>
										<td class="td-record">&nbsp;' . $value['sched_from'] . ' - '. $value['sched_to'] . '</td>
										<td class="td-record">&nbsp;' . $value['section_desc'] . '</td>
										<td class="td-record">&nbsp;' . $lecLabBoth . '</td>
										<td class="td-record">&nbsp;' . $value['first_name'] . ' '. $value['last_name'] . '</td>
									</tr>';
				}
			}	
					
			$TEMP->set_var(array('request_listing' => $html . $subj_list));
													
			$TEMP->parse('studentsRow', 'students', true);
			
			$numCount++;
		}
	}
	else {
		$TEMP->set_var(array('request_listing' => ''));
	}
	
	if ( isset($_POST['accept_status']) ) {
		$if_error	= 0;
		$acceptstatus = _POST('accept_status');
		if ( $if_error == 0 ) {
			$STUD->updateIrregularStudentSection($studID, $semLinkID, $acceptstatus, $strAccNo);
			$if_display = 1;
		}
	}
	else {
		$if_display	 = 0;
		$if_error	 = 0;
		$_txtsection = '';
	}
	$defaultSections = $STUD->getDefaultSections($courseID, $profSectionList['section_idFK'], $semLinkID);

	$inputSectionList = '<input type="hidden" name="txtsection" id="txtsection" value="' . $profSectionList['section_idFK'] . '"><span class="semester-page-width"><strong>'. $defaultSections[0]['section_desc'] . '</strong></span>';
	
	$TEMP->set_var(array('section'		=> $inputSectionList,
						 'section_desc'	=> $sectionDesc,
						 'course_label'	=> $courseDesc . ' (' . $courseCode . ')',
						 'sy_label'		=> $__SYR__,
						 'name'			=> $strName,
						 'if_display'	=> $if_display
						));

?>